package com.ruoyi.project.user.cancelaccount.service.impl;

import java.util.List;

import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.user.kkuser.domain.KKUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.user.cancelaccount.mapper.CancelAccountMapper;
import com.ruoyi.project.user.cancelaccount.domain.CancelAccount;
import com.ruoyi.project.user.cancelaccount.service.ICancelAccountService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 注销用户Service业务层处理
 *
 * @author shixiangwen
 * @date 2022-10-11
 */
@Service
@DataSource(DataSourceType.ACCOUNT)
public class CancelAccountServiceImpl implements ICancelAccountService {
    @Autowired
    private CancelAccountMapper cancelAccountMapper;

    /**
     * 查询注销用户
     *
     * @param id 注销用户ID
     * @return 注销用户
     */
    @Override
    public CancelAccount selectCancelAccountById(Long id) {
        return cancelAccountMapper.selectCancelAccountById(id);
    }

    /**
     * 查询注销用户列表
     *
     * @param cancelAccount 注销用户
     * @return 注销用户
     */
    @Override
    public List<CancelAccount> selectCancelAccountList(CancelAccount cancelAccount) {
        return cancelAccountMapper.selectCancelAccountList(cancelAccount);
    }

    @Override
    public CancelAccount queryCancelAccount(String appId, String userId) {
        CancelAccount query = new CancelAccount();
        query.setApp(appId);
        query.setUserId(userId);
        List<CancelAccount> cancelAccounts = cancelAccountMapper.selectCancelAccountList(query);
        if (!cancelAccounts.isEmpty()) {
            return cancelAccounts.get(0);
        }
        return null;
    }

    /**
     * 新增注销用户
     *
     * @param cancelAccount 注销用户
     * @return 结果
     */
    @Override
    public int insertCancelAccount(CancelAccount cancelAccount) {
        return cancelAccountMapper.insertCancelAccount(cancelAccount);
    }

    /**
     * 修改注销用户
     *
     * @param cancelAccount 注销用户
     * @return 结果
     */
    @Override
    public int updateCancelAccount(CancelAccount cancelAccount) {
        return cancelAccountMapper.updateCancelAccount(cancelAccount);
    }

    /**
     * 删除注销用户对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCancelAccountByIds(String ids) {
        return cancelAccountMapper.deleteCancelAccountByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除注销用户信息
     *
     * @param id 注销用户ID
     * @return 结果
     */
    @Override
    public int deleteCancelAccountById(Long id) {
        return cancelAccountMapper.deleteCancelAccountById(id);
    }
}
